document.addEventListener('keydown', function(event) {
  const key = event.key.toLowerCase();
  console.log('按键被按下:', key);
  
  chrome.runtime.sendMessage({
    action: 'keyPressed',
    key: key
  }, function(response) {
    if (chrome.runtime.lastError) {
      console.error('发送按键消息失败:', chrome.runtime.lastError);
    } else {
      console.log('按键消息发送成功:', response);
    }
  });
});

console.log('内容脚本已加载'); 